<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderPaymentsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('order_payments', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->bigInteger('order_id')->index()->comment('订单ID');
            $table->string('merchant_no')->comment('收款商户号');
            $table->string('out_order_no', 64)->unique()->comment('订单号');
            $table->integer('pay_amount')->comment('用户支付金额');
            $table->integer('receive_amount')->nullable()->comment('实收金额');
            $table->integer('platform_receive_amount')->nullable()->comment('平台收款金额');
            $table->integer('agent_receive_amount')->nullable()->comment('代理分账金额');
            $table->integer('user_receive_amount')->nullable()->comment('用户分账金额');
            $table->string('pay_way')->comment('支付方式');
            $table->dateTime('pay_time')->nullable()->comment('支付时间');
            $table->string('pay_status', 16)->comment('支付状态');
            $table->string('divide_status', 16)->default(\App\Enums\DivideStatus::INIT)->comment('分账状态');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('order_payments');
    }
}
